﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;



using Meqs.Entity;
using Meqs.Logic.Interface;

using Castle.Services.Transaction;
using Castle.Facilities.IBatisNetIntegration;
using log4net;

namespace Meqs.Logic.Implement
{
    public class TeacherEvalTypeLogic : CommonLogic<TeacherEvalType, int>, ITeacherEvalTypeLogic
    {
        #region Implementation of ICommonLogic<TeacherEvalType, int>

        /// <summary>
        /// 创建对象
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int Create(TeacherEvalType entity)
        {
            return CreateObject(entity);
        }

        /// <summary>
        /// 更新对象
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int Update(TeacherEvalType entity)
        {
            return UpdateObject(entity);
        }

        /// <summary>
        /// 删除对象
        /// </summary>
        /// <param name="entityId"></param>
        /// <returns></returns>
        public int Delete(int entityId)
        {
            return DeleteObject(entityId);
        }

        /// <summary>
        /// 删除所有对象
        /// </summary>
        /// <returns></returns>
        public int DeleteAll()
        {
            return DeleteAllObject();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="entityId"></param>
        /// <returns></returns>
        public TeacherEvalType FindById(int entityId)
        {
            return FindObjectById(entityId);
        }

        /// <summary>
        /// 检索对象数量
        /// </summary>
        /// <returns></returns>
        public int FindCount()
        {
            return FindObjectByCount();
        }

        /// <summary>
        /// 检索对象
        /// </summary>
        public IList<TeacherEvalType> FindAll()
        {
            return FindAllObject();
        }

        /// <summary>
        /// 检索对象数量
        /// </summary>
        /// <returns></returns>
        public int FindCount(Hashtable table)
        {
            return FindObjectByCount(table);
        }

        /// <summary>
        /// 检索对象
        /// </summary>
        public IList<TeacherEvalType> FindAll(Hashtable table)
        {
            return FindObject(table);
        }

        #endregion
         /// <summary>
        /// 验证名字重复
        /// </summary>
        /// <param name="p"></param>
        /// <param name="historyId"></param>
        /// <param name="causeId"></param>
        /// <param name="typeName"></param>
        /// <returns></returns>
        public int ValidateTypeName(string p, int historyId,  string typeName)
        {
            Hashtable table = new Hashtable();
            table.Add("SchoolMark", p);

            table.Add("historyId", historyId);
            table.Add("typeName", typeName);
            int result = 0;
            try
            {
                result = FindCustomerByCount("TeacherEvalType.ValidateTypeName", table);
            }
            catch (Exception e)
            {
                throw;
            }

            return result;
        }
        /// <summary>
        /// 插入类型
        /// </summary>
        /// <param name="p"></param>
        /// <param name="historyId"></param>
        /// <param name="typeName"></param>
        /// <returns></returns>
        public int InsertType(string p, int historyId, string typeName)
        {
            Hashtable table = new Hashtable();
            table.Add("SchoolMark", p);
            table.Add("historyId", historyId);
            table.Add("typeName", typeName);
            int result = 0;
            try
            {
                result = (int)InsertCustomer("TeacherEvalType.InsertType", table);
            }
            catch (Exception e)
            {
                throw;
            }

            return result;
        }


        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="ht"></param>
        /// <returns></returns>
        public int Delete(Hashtable ht)
        {
            try
            {
                string statementName = "TeacherEvalType.DeleteById";
                return ExecuteDelete(statementName, ht);
            }
            catch (Exception ex)
            {
                throw;
            }
        }

        /// <summary>
        /// 更新名字
        /// </summary>
        /// <param name="ht"></param>
        /// <returns></returns>
        public int UpdateTypeName(Hashtable ht)
        {
            try
            {
                string statementName = "TeacherEvalType.UpdateName";
                return ExecuteUpdate(statementName, ht);
            }
            catch (Exception ex)
            {
                throw;
            }
        }

        /// <summary>
        /// 获取关于教师的评估大类
        /// </summary>
        /// <param name="schoolMark"></param>
        /// <param name="schoolYear"></param>
        /// <param name="term"></param>
        /// <param name="historyId"></param>
        /// <param name="site">学生学分-StuCause，教师系统-Teacher</param>
        /// <returns></returns>
        public IList<TeacherEvalType> GetTeachHisType(string schoolMark, int schoolYear, int term, int historyId,string site)
        { 
            Hashtable table = new Hashtable();
            table.Add("SchoolMark", schoolMark);
            table.Add("schoolYear", schoolYear);
            table.Add("term", term);
            table.Add("historyId", historyId);
            table.Add("site", site);

            return FindCustomer<TeacherEvalType>("TeacherEvalType.GetTeachHisType", table);
        }
    }
}
